<?php 
namespace app\index\controller;

class Admin extends Common
{
    /**
     * 修改密码
     */
    public function edit_password()
    {
        $data['password'] = input('password','','trim');
        if (!$data['password']) returnError("密码不能为空");
        if (strlen($data['password']) < 6) returnError("密码不能少于6位");
        $requert = db('jujian')->where('bh',$this->bh)->update(['passwd' => md5($data['password'])]);
        if($requert>0){
            $operation_category = 55;
            $detail_name = array('修改密码','登录用户编号','修改后密码');
            $operation_value = array('成功',$this->id,'******');
            $re_name = ['updata_passwd'];
            $re_value = ['1'];
            $arr = array_combine($detail_name, $operation_value);
            $redis = array_combine($re_name, $re_value);
            $this->riZhi($operation_category, $arr, $redis);
            returnSuccess($data,"密码修改成功!");
        }else{
            $oldPwd = db('jujian')->where("bh",$this->bh)->value("passwd");
            if ($oldPwd == md5($data['password'])){
                returnSuccess($data,"操作成功!");
            }else {                
                returnError("操作失败！");
            }
        }
    }
    
    
}
 ?>